package com.zuipin.enums;

import com.zuipin.util.StringUtil;

public enum DeviceType {
	
	PC("PC", 0L), // //
	WAP("WAP", 1L); // //
	
	private Long	index;
	private String	value;
	
	private DeviceType(String value, Long index) {
		this.value = value;
		this.index = index;
	}
	
	public Long getIndex() {
		return index;
	}
	
	public void setIndex(Long index) {
		this.index = index;
	}
	
	public String getValue() {
		return value;
	}
	
	public void setValue(String value) {
		this.value = value;
	}
	
	public static String getValueByIndex(Long index) {
		if (index != null) {
			for (DeviceType c : DeviceType.values()) {
				if (c.index.equals(index)) {
					return c.value;
				}
			}
		}
		return null;
	}
	
	public static Long getIndexByValue(String value) {
		if (!StringUtil.isBlank(value)) {
			for (DeviceType c : DeviceType.values()) {
				if (c.value.equals(value)) {
					return c.index;
				}
			}
			
		}
		return null;
	}
}
